﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MobileShop.Controls
{
    public partial class SiteMap : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        public const string SLASH = "<span class='slash'>&nbsp;</span>";

        public void SetPath(string path)
        {
            string template = "<a href='{1}' >{0}</a>";
            string[] paths = path.Split(new string[]{"|"}, StringSplitOptions.RemoveEmptyEntries);
            string html = "";
            for (int i = 0; i < paths.Length; i++)
            {
                string[] items = paths[i].Split(new string[] { "[", "]" }, StringSplitOptions.RemoveEmptyEntries);
                string text = items.Length > 0 ? items[0] : "";
                string url = items.Length > 1 ? items[1] : "";
                html += SLASH;
                html += string.Format(template, text, url); 
            }

            litPageMap.Text = html;
        }
    }
}